﻿using System;
using System.Collections.Generic;
using ContractManager.Entity;
using Speed.Data;

namespace ContractManager.BLL.Business
{
    public static class ClsContractDetails
    {
        public static List<ContractDetails> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.ContractDetails.Select(db);
            }
            
        }

        public static void Insert(ContractDetails capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<ContractDetails>(capital);
            }
            
        }

        public static void Update(ContractDetails capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<ContractDetails>(capital);
            }
            
        }

        public static ContractDetails SelectByPk(Int32 conId)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<ContractDetails>(string.Format("ConDetId={0}", conId));
            }
            
        }

        public static List<ContractDetails> SelectByMaster(Int32 conId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Select<ContractDetails>(string.Format("ConId={0}", conId));
            }
            
        }

        public static int DeleteByPk(Int32 conId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<ContractDetails>(string.Format("ConDetId={0}", conId));
            }
            
        }
    }
}